<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字符串大小写转换</title>
</head>
<body>
<h2>大小写转换</h2>
原数据:<input id ="old" type="text">
<br />
<br />
<br />
操作:
<input type="button" value="转大写" onclick="deal('upper')">    //让字符串都变成大写的按钮
<input type="button" value="转小写" onclick="deal('lower')">    //让字符串都变成小写的按钮
<br />
<br />
<br />
新数据:
<input id="new" type="text">   //输出新数据
<script>
    function deal(opt){
        var str = document.getElementById('old').value;
        switch(opt)
         {
             case 'upper':  //检测单击转大写按钮
                 str =str.toUpperCase();
                 break;
             case 'lower':  //检测单击转小写按钮
                 str =str.toLowerCase();
                 break;
         }
        document.getElementById('new').value =str;
    }
</script>
</body>
</html>